//
//  HZJSaveViewController.swift
//  HZJGTEST
//
//  Created by 运车管家 on 2017/8/25.
//  Copyright © 2017年 运车管家. All rights reserved.
//

import UIKit

class HZJSaveViewController: HZJBaseTabViewController {
    
    var typeArray:[String] = []
    
    let bcV = UIView()
    
    override func viewDidLoad() {
        super.viewDidLoad()
        self.title = "选择类型"
        self.edgesForExtendedLayout = .all
        self.view.backgroundColor = .white

        
//        self.myNavigationBar.tintColor = .brown
//        self.myNavigationBar.isTranslucent = true
//        self.myNavigationBar.setBackgroundImage(UIImage(), for: .default)
        self.myRightBtn.isHidden = true
        typeArray = ["one","two","three","four","one","two","three","four","one","two","three","four","one","two","three","four"]
        
        self.tabView.register(HZJImgTableViewCell.self, forCellReuseIdentifier: "HZJImgTableViewCell")
        
    }
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    //mark: - UITableViewDataSource
    override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return typeArray.count
    }
    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = HZJImgTableViewCell(style: .subtitle, reuseIdentifier: "HZJImgTableViewCell")
        cell.titleLab?.text = typeArray[indexPath.row]
        cell.titleLab?.textColor = .random
        return cell
    }

    //mark: - tableviewDelegate
    
    override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        tableView.deselectRow(at: indexPath, animated: true)
        let vc = HZJInfoViewController()
        self.navigationController?.pushViewController(vc, animated: true)
    }
    
}

class HZJImgTableViewCell: UITableViewCell {
    
    var backImageView:UIImageView? //背景大图
    var bottomLine:UIView?         //底部分割线
    var titleLab:UILabel?          //中心文字
    
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super .init(style: style, reuseIdentifier: reuseIdentifier)
        setUpUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    func setUpUI(){
        backImageView = UIImageView()
        self.addSubview(backImageView!)
        bottomLine = UIView()
        bottomLine?.backgroundColor = .black
        self.addSubview(bottomLine!)
        titleLab = UILabel()
        titleLab?.textAlignment = .center
        titleLab?.font = UIFont.systemFont(ofSize: 22)
        self.addSubview(titleLab!)
    }
    
    override func layoutSubviews() {
        super.layoutSubviews()
        backImageView!.frame = self.frame
        bottomLine!.frame = CGRect(x: 0, y: self.contentView.frame.height - 0.5, width: self.frame.width, height: 0.5)
        titleLab?.frame = CGRect(x: 0, y: 0, width: self.frame.width, height: self.frame.height)
        
    }
}
